﻿using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Common.Configuration
{
    public class ConfigurationHelper
    {
        private static IConfiguration? configuration;
        private static object locker = new object();
        public static IConfiguration GetIConfiguration()
        {
            if(configuration == null)
            {
                lock (locker)
                {
                    if (configuration == null)
                    {
                        var builder = new ConfigurationBuilder()
                           .SetBasePath(Directory.GetCurrentDirectory())
                           .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
                        configuration= builder.Build();
                    }
                }
            }
            return configuration;
        }
    }
}
